package com.hinnotek.amoeba.ui.activity.old

import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.lee.common.base.BaseActivity
import com.hinnotek.amoeba.R
import com.hinnotek.amoeba.adapters.old.SellListAdapter
import com.hinnotek.amoeba.databinding.ActivityTechnologyListBinding
import com.hinnotek.amoeba.ui.fragment.FragmentHomeWork
import com.hinnotek.amoeba.utilities.IntentUtils

class TechnologyListActivity : BaseActivity<ActivityTechnologyListBinding>() {
    private var adapter: SellListAdapter? = null
    private val strings = arrayOf("采购申请", "付款申请", "报销申请", "安装申请", "临时/续费缴费申请")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setLeftVisible(true)
        setTitle("技术列表")

        setContentView(R.layout.activity_technology_list)
        initVew()
    }

    override fun initVew() {
        val manager = GridLayoutManager(mContext, 3)
        manager.orientation = LinearLayoutManager.VERTICAL
        bindingView.recyclerView.layoutManager = manager
        bindingView.recyclerView.adapter = SellListAdapter().also { adapter = it }
        adapter?.setOnItemClickListener { adapter1: BaseQuickAdapter<*, *>, _: View?, position: Int ->
            val s: String = (adapter1.getItem(position) as FragmentHomeWork.Bean).tv
            when (s) {
                "采购申请" -> {
                    val bundle = Bundle()
                    bundle.putString("purchase_type_to", "technology")
                    IntentUtils.startActivity(
                        mContext,
                        SellPurchaseRequisitionActivity::class.java,
                        bundle
                    )
                }
                "付款申请" -> IntentUtils.startActivity(
                    mContext,
                    PaymentRequestListActivity::class.java
                )
                "报销申请" -> {
                    val bundle1 = Bundle()
                    bundle1.putInt("applyUserType", 2)
                    bundle1.putString("purchase_type_to", "technology")
                    IntentUtils.startActivity(mContext, WipeOutListActivity::class.java, bundle1)
                }
                "安装申请" -> IntentUtils.startActivity(
                    mContext,
                    TechnologyInstallListActivity::class.java
                )
                "维修申请" -> IntentUtils.startActivity(
                    mContext,
                    TechnologyInstallListActivity::class.java
                )
                "维护申请" -> IntentUtils.startActivity(
                    mContext,
                    TechnologyInstallListActivity::class.java
                )
                "临时/续费缴费申请" -> IntentUtils.startActivity(
                    mContext,
                    RenewalPaymentListActivity::class.java
                )
            }
        }
        setData()
    }

    override fun setData() {
        val stringList: MutableList<FragmentHomeWork.Bean> = mutableListOf()
        stringList.add(FragmentHomeWork.Bean(R.drawable.purchase, "采购申请"))
        stringList.add(FragmentHomeWork.Bean(R.drawable.pay, "付款申请"))
        stringList.add(FragmentHomeWork.Bean(R.drawable.wipe_out, "报销申请"))
        stringList.add(FragmentHomeWork.Bean(R.drawable.install, "安装申请"))
        stringList.add(FragmentHomeWork.Bean(R.drawable.renewal, "临时/续费缴费申请"))
        adapter?.setList(stringList.toMutableList())
    }
}